package mock.servicesdirectory.organisations.dao.daoimpl;

import java.util.List;

import mock.servicesdirectory.common.entities.Department;
import mock.servicesdirectory.common.entities.Directorate;
import mock.servicesdirectory.organisations.dao.daointerface.DepartmentDAO;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class DepartmentDAOImpl extends HibernateDaoSupport implements DepartmentDAO{

	// Get all department 
	@Override
	public List<Department> getDepartment() {
		// TODO Auto-generated method stub
		return getHibernateTemplate().find("from Department");
	}

	// Get department of a directorate
	@Override
	public List<Department> getDepartment(int directorateId) {
		// TODO Auto-generated method stub
		String sql;
		List<Department> department;
		sql = "from Department where DirectorateId = :directorateId";
		Session session = this.getSession();
		Query query = session.createQuery(sql);
		query.setParameter("directorateId", directorateId);
		department = query.list();
		return department;
	}

	// filter department by a flag
	/*
	 * flag = 1 . Name start with a digit 0-9
	 * flag = 2 . Name start with A, B, C, D ,E
	 * flag = 3 . Name start with F, G, H, I, J
	 * flag = 4 . Name start with K, L, M, N
	 * flag = 5 . Name start with 0, P, Q , R
	 * flag = 6 . Name start with S, T, U , V
	 * flag = 7 . Name start with W, Y, Z
	 */
	@Override
	public List<Department> getDepartment(int directorateId, int flag) {
		// TODO Auto-generated method stub
		return null;
	}

	// Check exist department by name
	@Override
	public boolean checkExistDepartment(String name) {
		// TODO Auto-generated method stub
		return false;
	}

}
